Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize nth_value, remove first_value, last_value structs and use idiomatic rust style #452

Merged
merged 2 commits into from
Jun 1, 2021

Conversation

jimexist
Copy link
Member

@jimexist jimexist commented May 31, 2021

Which issue does this PR close?

Closes #448 .

Rationale for this change

we can:

  1. reduce num of constructs in implementing nth_value
  2. further reuse code

What changes are included in this PR?

Are there any user-facing changes?

@jimexist jimexist marked this pull request as draft May 31, 2021 01:52
@codecov-commenter
Copy link

codecov-commenter commented May 31, 2021

Codecov Report

Merging #452 (21b2be0) into master (c8ab5a4) will increase coverage by 0.06%.
The diff coverage is 96.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #452      +/-   ##
==========================================
+ Coverage   75.30%   75.36%   +0.06%     
==========================================
  Files         152      152              
  Lines       25275    25294      +19     
==========================================
+ Hits        19033    19063      +30     
+ Misses       6242     6231      -11     
Impacted Files Coverage Δ
datafusion/src/physical_plan/expressions/mod.rs 71.42% <ø> (ø)
...afusion/src/physical_plan/expressions/nth_value.rs 90.47% <96.72%> (+19.70%) ⬆️
datafusion/src/physical_plan/windows.rs 87.12% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8ab5a4...21b2be0. Read the comment docs.

@jimexist jimexist marked this pull request as ready for review May 31, 2021 11:07
@jimexist jimexist changed the title Optimize nth_value, remove first_value, last_value structs and use idiomatic rust style Optimize nth_value, remove first_value, last_value structs and use idiomatic rust style May 31, 2021
@jimexist
Copy link
Member Author

@alamb as promised :-)

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added tests are great. Thanks @jimexist -- and I think the code looks great too. 👍

fn test_i32_result(expr: Arc<NthValue>, expected: i32) -> Result<()> {
let arr: ArrayRef = Arc::new(Int32Array::from(vec![1, -2, 3, -4, 5, -6, 7, 8]));
let schema = Schema::new(vec![Field::new("arr", DataType::Int32, false)]);
let batch = RecordBatch::try_new(Arc::new(schema), vec![arr])?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW for tests like this you can also use RecordBatch::try_from_iter to avoid having to construct the Schema directly.

This way is great too, I just figured I would point it out for the future

@alamb alamb merged commit aab40f8 into apache:master Jun 1, 2021
@jimexist jimexist deleted the optimize-nth branch June 1, 2021 23:49
@houqp houqp added the datafusion Changes in the datafusion crate label Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use a more rust idiomatic way of handling nth_value
4 participants